package com.ipjmc.demo.scroll;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class ScrollActivity extends Activity implements View.OnClickListener{
	
	private static final String TAG = "TestScroll";
	private Button mUp, mDown;
	private TextView mTextView;
	private ListView mListView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		mTextView = (TextView) findViewById(R.id.text);
		mUp = (Button) findViewById(R.id.up);
		mDown = (Button) findViewById(R.id.down);
		mListView = (ListView) findViewById(R.id.list);

		//mListView.scrollTo(0, 50);
		
		mUp.setOnClickListener(this);
		mDown.setOnClickListener(this);
		
		Log.i(TAG, "mTextView.getScrollXY() = "+mTextView.getScrollX() +","+ mTextView.getScrollY()+"---"
				   + " mListView.getBaseline() = " + mListView.getScrollY());
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.up:
			Log.i(TAG, "mtextWH:"+mTextView.getWidth()+","+mTextView.getHeight());	
			Log.i(TAG, "mtextPadding:"+mTextView.getPaddingLeft()+","+mTextView.getPaddingRight());	
			
			mTextView.scrollBy(0, 10);
			mListView.scrollBy(0, 10);
			Log.i(TAG, "mTextView.getScrollY() = " + mTextView.getScrollY()
				   + ", mListView.getBaseline() = " + mListView.getScrollY());
			break;
		case R.id.down:
			mTextView.scrollBy(0, -10);
			mListView.scrollBy(0, -10);
			
			Log.i(TAG, "mTextView.getScrollY() = " + mTextView.getScrollY()
					   + ", mListView.getBaseline() = " + mListView.getScrollY());
			break;
		default:
			break;
		}
	}

}